package com.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dao.CunkuanxinxiDao;
import com.entity.Cunkuanxinxi;
import com.service.CunkuanxinxiService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CunkuanxinxiServiceImpl extends ServiceImpl<CunkuanxinxiDao, Cunkuanxinxi> implements CunkuanxinxiService {

    @Resource
    private CunkuanxinxiDao cunkuanxinxiDao;



    @Override
    public Page page(Cunkuanxinxi cunkuanxinxi) {
        // 创建分页对象
        Page<Cunkuanxinxi> page = new Page<>(cunkuanxinxi.getPage(), cunkuanxinxi.getLimit());
        // 创建查询条件（使用 EntityWrapper）
        EntityWrapper<Cunkuanxinxi> wrapper = new EntityWrapper<>();
        String cunkuanmingcheng = cunkuanxinxi.getCunkuanmingcheng();
        if(StringUtils.isNotBlank(cunkuanmingcheng)){
            wrapper.like("cunkuanmingcheng",cunkuanmingcheng);
        }
        List<Cunkuanxinxi> cunkuanxinxis = cunkuanxinxiDao.selectPage(page, wrapper);
        page.setRecords(cunkuanxinxis);
        return page;
    }



}
